package com.jiarong.repository.impl;

import com.jiarong.repository.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author 加绒
 * @date 2021/10/20 16:32
 */
@Repository("accountDao")
public class AccountDaoImpl implements AccountDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void expenditure(String payer, Double money) {
        jdbcTemplate.update("update account set money = money - ? where name = ?", money, payer);
    }

    @Override
    public void income(String payee, Double money) {
        jdbcTemplate.update("update account set money = money + ? where name = ?", money, payee);
    }
}
